﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
	<link href="js-console.css" rel="stylesheet" />
	<!-- 6. Write an expression that checks if given print (x,  y) 
			is within a circle K(O, 5). -->
</head>
<body>
	<div id="js-console"></div>
	<script src="js-console.js"></script>
	<script>
		//Point coordinates (x, y)
		var pointX = prompt("Enter X coordinate");
		var pointY = prompt("Enter Y coordinate");

		if (!isNaN(pointX) && !isNaN(pointY)) {
			pointX *= 1; pointY *= 1;	// make them real number
			// Circle with center point (0, 0)
			var circleRadius = 5;

			// Result
			var result =
				((pointX * pointX) + (pointY * pointY)) < (circleRadius * circleRadius);

			var resultString = String.Empty;
			if (result)
			{ resultString = "within"; }
			else
			{ resultString = "outside"; }

			// Output
			jsConsole.writeLine("Point with coordinates (" + pointX + "," + pointY + ") is " +
									resultString + " a circle with radius " + circleRadius);
		}
		else {
			jsConsole.writeLine("Not a Number.");
		}
	</script>
</body>
</html>
